<?php
  //set session save path
  session_save_path($session_path);
  // Initialize a session. 
  session_start(  );
            //session_destroy();             
  $count++;                         
  $sessionId = session_id();
if ($Submit) {
    $adminmail = "<josh@joshhughes.com>";
    $MailFrom = "football@joshhughes.com";
    $MailSubject = "Football Pool Suggestions";//"NEWS from $dfilename";
    $MailBody = "$SuggesterName <$SuggesterEmail> made the following suggestion:\n$Suggestion";
    $MailTo = $adminmail;
    $MailFrom = "From: $MailFrom";
    //Send an Email to me notifying me of a request
    mail($MailTo, $MailSubject, $MailBody, $MailFrom);  //message send
?>
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript"><!--
function redirect () { setTimeout("go_now()",10000); }
function go_now ()   { window.location.href = "<?= $PHP_SELF; ?>"; }
//--></SCRIPT>
</HEAD>
<BODY onLoad="redirect()" bgcolor="#CCCCCC">
<H2>Thank you <?= $SuggesterName; ?> for you suggestion.</H2>
This page will automatically redirect in 10 seconds.
</BODY>
</HTML>
<?
} else {
    if ($userID) {
	include 'include/functions.php';

	//Connect To Database
	dbConnect();
	
	$result = mysql_query("SELECT Username, Email FROM NFLUsers WHERE ID = $userID") or die("Cannot query the database.<br>" . mysql_error());
	if($myrow = mysql_fetch_array($result)) {
		$FromName = $myrow["Username"];
		$FromEmail = $myrow["Email"];
	}
	?>
	<head>
	<link rel="stylesheet" href="css/NFLPool.css" type="text/css">
	</head>
	<form action="<?= $PHP_SELF; ?>" method="POST">
	<table bgcolor="#CCCCCC">
	  <tr>
	    <td>Name:</td>
	  </tr>
	  <tr>
	    <td><input disabled type="text" value="<?= $FromName; ?>"><input type="hidden" name="SuggesterName" value="<?= $FromName; ?>"></td>
	  </tr>
	  <tr>
	    <td>Email:</td>
	  </tr>
	  <tr>
	    <td><input disabled type="text" value="<?= $FromEmail; ?>"><input type="hidden" name="SuggesterEmail" value="<?= $FromEmail; ?>"></td>
	  </tr>
	  <tr>
	    <td>Suggestion:</td>
	  </tr>
	  <tr>
	    <td align="Left">
		<textarea cols="17" rows="5" name="Suggestion">
		</textarea>
	    </td>
	  </tr>
	  <tr>
	    <td align="Center"><input type="Submit" name="Submit" value="Submit"> <input type="reset" value="Reset!"></td>
	  </tr>
	</table>
	</form>
<?
    } else {
?>
<head>
<link rel="stylesheet" href="css/NFLPool.css" type="text/css">
</head>
<form action="<?= $PHP_SELF; ?>" method="POST">
<table bgcolor="#CCCCCC">
  <tr>
    <td>Name:</td>
  </tr>
  <tr>
    <td><input type="text" name="SuggesterName"></td>
  </tr>
  <tr>
    <td>Email:</td>
  </tr>
  <tr>
    <td><input type="text" name="SuggesterEmail"></td>
  </tr>
  <tr>
    <td>Suggestion:</td>
  </tr>
  <tr>
    <td align="Left">
	<textarea cols="17" rows="5" name="Suggestion">
	</textarea>
    </td>
  </tr>
  <tr>
    <td align="Center"><input type="Submit" name="Submit" value="Submit"> <input type="reset" value="Reset!"></td>
  </tr>
</table>
</form>
<?
    }//end if ($UserID)
}//end if($Submit)
?>